﻿<%@ Page Title="S&S月度结算单" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
    <link href="../assets/css/plugins/webuploader/webuploader.css" rel="stylesheet" />
    <link href="../assets/img/validate/validate.css" rel="stylesheet">
    <style type="text/css">
        .system-box .right-side {
            width: 100%;
        }

        .condition, .condition-title {
            border-bottom: 1px solid #dfdfdd;
        }

            .condition .form-control {
                padding: 2px 6px;
            }

        .module-info td .control-label {
            margin-right: 0px;
            width: 70px;
        }
        .printTitle{
           width:100%;
           font-size:18px;
           text-align:center;
        }
        .my-heder {
            width: 100%;
            margin-top: 20px;
            text-align: left;
        }

            .my-heder td {
                width: 33%;
            }

        .tab-sale-dtl {
            border-collapse: collapse;
            border-spacing: 0;
            border-left: 1px solid #888;
            border-top: 1px solid #888;
            background: #f5f5f5;
            width: 100%;
        }

            .tab-sale-dtl td {
                border-right: 1px solid #888;
                border-bottom: 1px solid #888;
                padding: 0px;
                /*width: 33%;*/
                text-align: center;
            }
          label {
              font-weight:400 ;
          }

        .PrintFormat_td {
            vertical-align: top;
        }
        .PrintFormat_span {
            display: block;
            float: left;
            width: 76px;
        }
        .PrintFormat_label {
            float: left;
            width: 60%;
        }

    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="container">
        <div class="printTitle">S&S月度结算单</div>
        <%--<div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                            <label class="col-sm-2 control-label">结算单号：</label>
                            <div class="col-sm-8">
                                <label id="BalanceCode"  class="pull-right"></label>
                            </div>
                        </div>
                   <div class="form-group">
                            <label class="col-sm-2 control-label">合同号：</label>
                            <div class="col-sm-6">
                                <label id="Client-ContractCode"  class="pull-right"></label>
                            </div>
                        </div>
            </div>
             <div class="col-sm-6">
                 
                  <div class="form-group">
                            <label class="col-sm-2 control-label">品牌：</label>
                            <div class="col-sm-6">
                                <label id="CompanyID"  class="pull-right"></label>
                            </div>
                        </div>
                  <div class="form-group">
                            <label class="col-sm-2 control-label">结算期间：</label>
                            <div class="col-sm-6">
                                <label id="BalanceDate"  class="pull-right"></label>
                            </div>
                        </div>
                 </div>
        </div>--%>
        <div style="width: 100%; padding: 20px 45px; text-align: center;">
            <table class="my-heder">
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">结算&nbsp;单号：</span>
                        <label class="PrintFormat_label" id="BalanceCode"></label>
                    </td>
                   <td class="PrintFormat_td">
                       <span class="PrintFormat_span">品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;牌：</span>
                        <label class="PrintFormat_label" id="CompanyID"></label>
                   </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">合&nbsp;&nbsp;同&nbsp;&nbsp;号：</span>
                        <label class="PrintFormat_label" id="Client-ContractCode"></label>
                    </td>

                  <td class="PrintFormat_td">
                        <span class="PrintFormat_span">结算&nbsp;期间：</span>
                        <label class="PrintFormat_label" id="BalanceDate"></label>
                    </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">代&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</span>
                        <label class="PrintFormat_label" id="ClientCode"></label>
                    </td>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">制单&nbsp;日期：</span>
                        <label class="PrintFormat_label" id="CreateDate"></label>
                    </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称：</span>
                        <label  class="PrintFormat_label" id="RegistName"></label>
                    </td>
                    
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称：</span>
                        <label class="PrintFormat_label" id="CompanyName"></label>
                    </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">证&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span>
                        <label class="PrintFormat_label" id="RegistCode"></label>
                    </td>
                    
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">税&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span>
                        <label class="PrintFormat_label" id="TaxNumber"></label>
                    </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：</span>
                        <label class="PrintFormat_label" id="RegistAddress"></label>
                    </td>
                    
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：</span>
                        <label class="PrintFormat_label" id="CompanyAddress"></label>
                    </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">开&nbsp;&nbsp;户&nbsp;&nbsp;行：</span>
                        <label class="PrintFormat_label" id="Client-Bank"></label>
                    </td>
                    
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">开&nbsp;&nbsp;户&nbsp;&nbsp;行：</span>
                        <label class="PrintFormat_label" id="Company-Bank"></label>
                    </td>
                </tr>
                <tr>
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span>
                        <label class="PrintFormat_label" id="Client-AccountCode"></label>
                    </td>
                    
                    <td class="PrintFormat_td">
                        <span class="PrintFormat_span">账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span>
                        <label class="PrintFormat_label" id="Company-AccountCode"></label>
                    </td>
                </tr>
                 
                <%-- <tr>
                    <td colspan="3">
                         <span>合同状态：</span>
                        <label id="Client-ContractState"></label>
                    </td>
                
                </tr>--%>
            </table>
            <table class="my-heder">
                <tr>
                    <td style="text-align: left;">销售与结算明细</td>
                    
                    <td style="text-align: right;">金额：人民币元</td>
                </tr>
            </table>
            <table class="tab-sale-dtl">
                <thead>
                </thead>
                <tbody id="Data1">
                    <tr>
                        <td>类别</td>
                        <td>结算扣率</td>
                        <td>销售数量</td>
                        <td>销售金额</td>
                        <td>结算金额</td>
                    </tr>
                </tbody>
            </table>
            <table class="my-heder">
                <tr>
                    <td style="text-align: left;">本期结算汇总：</td>
                </tr>
            </table>
            <table class="tab-sale-dtl">
                <thead>
                </thead>
                <tbody id="Data2">
                    <tr>
                        <td>发票金额</td>
                        <td>不含税</td>
                        <td>税率</td>
                        <td>税额</td>
                        <td>应付金额</td>
                    </tr>
                </tbody>
            </table>
            <table class="my-heder" style="text-align: left;">
                <tr>
                    <td>审核信息：</td>
                    
                </tr>
                <tr>
                    <td>销售审核：<label id="CheckName"></label></td>
                    <td>财务审核：<label id="UserName"></label></td>
                </tr>
                <tr style="height: 80px;">
                    <td>被特许方（盖章）：</td>
                    <td>特许方（盖章）：</td>
                </tr>
            </table>
        </div>
        <div style="width:100%;text-align:right;" class="btn-list">
            <button type="button" id="BtnPrint" class="btn btn-primary">打印</button>
            <button type="button" class="btn btn-white closeBtn">关闭</button>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/img/validate/learunui-validator.js"></script>
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/rScroll.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/plugins/webuploader/webuploader.min.js"></script>
    <script src="../assets/js/framework.js"></script>
    <script src="../assets/js/plugins/bootstrap-typeahead/bootstrap-typeahead.js"></script>
    <script>

        $('document').ready(function () {
            //检测是否已登录
            if (Y.checkNull(window.sessionStorage.getItem('login-info'))) {
                window.location.href = 'login.aspx';
            }
            else {
                var data = sessionStorage.getItem('login-info');
                var d = $.parseJSON(data);
                $("#UserName").text(d.NickName);
            }

            //关闭当前标签页
            var closeActiveTab = function () {
                var closeBtn = $('.J_menuTab.active i', window.parent.document);
                closeBtn.click();
            }
            $('.closeBtn').click(function () {
                closeActiveTab();
            });

            var _CompanyID = Y.getUrlParam("CompanyID");
            var _ShopID = Y.getUrlParam("ShopID");
            var _BalanceDate = Y.getUrlParam("BalanceDate");

            var loadCompany = function (_CompanyID) {
                Y.API2('CsrdCompany', 'GetCompany', {
                    CompanyID: _CompanyID
                }, function (data) {
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        $("#CompanyID").text(_CompanyID);
                        $("#CompanyName").text(data.CompanyName);
                        $("#TaxNumber").text(data.TaxNumber);
                        $("#CompanyAddress").text(data.CompanyAddress);
                        $("#Company-Bank").text(data.BankName);
                        $("#Company-AccountCode").text(data.AccountCode);
                    }
                })
            }
            var loadClient = function (_ShopID) {
                Y.API2('Balance', 'GetClient', {
                    ShopID: _ShopID
                }, function (data) {
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        //console.log(data);
                        $("#ClientCode").text(data.ClientCode);
                        $("#RegistName").text(data.RegistName);
                        $("#RegistCode").text(data.RegistCode);
                        $("#RegistAddress").text(data.RedistAddress);
                        $("#Client-Bank").text(data.BankName);
                        $("#Client-AccountCode").text(data.AccountCode);
                        $("#CheckName").text(data.ShopLinkMan);
                        $("#Client-ContractCode").text(data.ContractCode);
                        //$("#Client-ContractState").text(data.ContractState);
                    }
                })
            }
            var loadBalanceData = function (_CompanyID, _ShopID) {
                Y.API2('Balance', 'GetBalaceDtl', {
                    CompanyID: _CompanyID,
                    ShopID: _ShopID,
                    BalanceDate: _BalanceDate
                }, function (data) {
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        console.log(data);
                        $("#BalanceCode").text(data.BalanceCode);
                        $("#BalanceDate").text(data.BalanceDate);
                        $("#CreateDate").text(data.CreateDate);
                        var _html = '<tr>'
                                + '      <td>A</td>'
                                + '      <td>' + data.Discount + '</td>'
                                + '      <td>' + data.Qty + '</td>'
                                + '      <td>' + data.RealAmount + '</td>'
                                + '      <td>' + data.BalanceAmount + '</td>'
                                 + '  </tr>';
                        $("#Data1").append(_html);

                        _html = '<tr>'
                                + '      <td>' + data.BalanceAmount + '</td>'
                                + '      <td>' + data.TaxFreeAmount + '</td>'
                                + '      <td>' + data.TaxRate + '</td>'
                                + '      <td>' + data.TaxAmount + '</td>'
                                + '      <td>' + data.BalanceAmount + '</td>'
                                 + '  </tr>';
                        $("#Data2").append(_html);
                    }
                })
            }
            loadCompany(_CompanyID);
            loadClient(_ShopID);
            loadBalanceData(_CompanyID, _ShopID);

            $('#BtnPrint').click(function () {
                $('.btn-list').hide();
                window.print();
                $('.btn-list').show();
            });
        });

    </script>
</asp:Content>

